<?php
class DataMainController extends CController
{
	public $defaultAction='getData';
	
	public function actionGetData()
	{
	    $models = array();
		$main = new pageMain;
		$keys = array();
		if (isset($_GET['adp']))
		{
			$keys[] = $_GET['adp'];
		} else {
			$keys = array_keys($main->getPositionOptions());
		}
		
		foreach ($keys as $key) {
			$criteria=new CDbCriteria;
			$criteria->condition='position='.$key;
			$model=pageMain::model()->findAll($criteria);
			$attributes = array();
			foreach ($model as $item) {
				$attributes[] = $item->attributes;
			}
			$models[$key]=$attributes;
		}
		echo json_encode($models);
	}
	
	public function actionInfoContent()
	{
		echo $_SERVER['REMOTE_ADDR'];
	}
}